package com.yuki312.backoff.ktx;


import com.yuki312.backoff.core.BinaryExponentialAlgorithm;
import com.yuki312.backoff.core.ExponentialAlgorithm;
import com.yuki312.backoff.core.RandomIntervalAlgorithm;

public class BackoffExt {

    public static ExponentialAlgorithm exponentialBackoff() {
        Long interval = ExponentialAlgorithm.DEFAULT_INTERVAL;
        Double multiplier = ExponentialAlgorithm.DEFAULT_MULTIPLIER;
        Long maxInterval = ExponentialAlgorithm.DEFAULT_MAX_INTERVAL;
        Double range = ExponentialAlgorithm.DEFAULT_RANGE;
        return new ExponentialAlgorithm(interval, multiplier, maxInterval, range);
    }

    public static BinaryExponentialAlgorithm binaryExponentialBackoff(){
        Long interval = ExponentialAlgorithm.DEFAULT_INTERVAL;
        Long maxInterval = ExponentialAlgorithm.DEFAULT_MAX_INTERVAL;
        Double range = ExponentialAlgorithm.DEFAULT_RANGE;
        return new BinaryExponentialAlgorithm(interval, maxInterval, range);
    }

    public static RandomIntervalAlgorithm randomInterval(){
        Long lowInterval = RandomIntervalAlgorithm.DEFAULT_LOW_INTERVAL;
        Long highInterval = RandomIntervalAlgorithm.DEFAULT_HIGH_INTERVAL;
        Double lowMultiplier = RandomIntervalAlgorithm.DEFAULT_LOW_MULTIPLIER;
        Double highMultiplier = RandomIntervalAlgorithm.DEFAULT_HIGH_MULTIPLIER;
        Long maxInterval = RandomIntervalAlgorithm.DEFAULT_MAX_INTERVAL;
        return new RandomIntervalAlgorithm(
                lowInterval, highInterval, lowMultiplier, highMultiplier, maxInterval);
    }
}